/* 用于定时更新步数 */

const schedule = require('node-schedule');
const model = require("../model/api/Step.js")
const likes = require("../model/api/Like.js")
const { localTime } = require("./index");
// 定义规则
let rule = new schedule.RecurrenceRule();
rule.hour = 8;
rule.minute = 54;
rule.second = 0;

/* 每天的凌晨重置 */


module.exports = schedule.scheduleJob(rule, async () => {
  try {
    const res = await model.update({}, { $set: { today: 0, time: localTime() }, }, { multi: true });
    const deleRes = await likes.remove({});
    console.log(res,deleRes)
  } catch (error) {
    console.log(error)
  }
});